/*
 * @Author: your name
 * @Date: 2022-01-20 17:20:53
 * @LastEditTime: 2022-01-20 19:46:10
 * @LastEditors: LAPTOP-L472H14P
 * @Description: In User Settings Edit
 * @FilePath: \react_front_engineer\src\NodeJs\fs\01成绩案例读写.js
 */
const fs = require("fs");
fs.readFile("./grade.txt","utf-8", (err,data)=>{
    if(err){
        console.log(err);
    }
    // console.log(data);
    const originData = data.split(' ');
    const targetData = [];
    originData.forEach(d=>{
        const newItem = d.replace("=",":");
        targetData.push(newItem);
    });
    const str = targetData.join("\r\n");
    fs.writeFile("./newGradde.txt", str, (err,data)=>{
        if(err){
            throw err;
        }else{
          console.log("文件写入成功");
        }
    })
})
console.log(__dirname);